package com.ccb.sc.common.modules.goods.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

/**
 * @author ken
 * @since 2020-09-15
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@Getter
public enum CategoryType implements IEnum<Integer> {

    /**
     * 积分商品
     */
    POINTS_GOODS_CATEGORY(1, "积分商品"),

    /**
     * 直播商品
     */
    LIVE_STREAMING_GOODS_CATEGORY(2, "直播商品"),

    /**
     * 主推新品
     */
    MAIN_PUSH(3, "主推新品"),

    /**
     * 店主商品
     */
    BLACK_BRICK(4, "黑钻王炸区"),

    ;

    private int value;
    private String desc;

    CategoryType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static CategoryType getByValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (CategoryType categoryType : CategoryType.values()) {
            if (categoryType.getValue() == value.intValue()) {
                return categoryType;
            }
        }
        return null;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }
}
